($ => {
    //// <summary>
    // 获取技师工作站页面的工具栏配置
    // params: json自定义参数
    // </summary>
    $.getTechnicianTools = ($eventEmitter, quickFilter, advancedSearch, examGrid, params) => {
        const handleClick = (toolId, data) => {
            $eventEmitter.trigger(toolId, {
                quickFilter,
                advancedSearch,
                examGrid,
                params,
                data
            });
        };
        const tools = {
            // 查看申请单
            viewApply: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_查看申请单',
                options: {
                    text: '查看申请单',
                    icon: '/icons/antd_filesearch.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('viewApply');
                    },
                }
            },
            // 查看患者详情
            openExam: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_查看患者详情',
                options: {
                    text: '患者详情',
                    icon: '/icons/antd_user.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('openExam');
                    },
                }
            },
            // 更换设备
            changeDevice: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_更换设备',
                options: {
                    text: '更换设备',
                    icon: '/icons/md_swap_horiz.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('changeDevice');
                    },
                }
            },
            // 呼叫下一位
            callNext: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_呼叫下一位',
                options: {
                    text: '呼叫下一位',
                    icon: '/icons/ionic_volume_medium.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('callNext');
                    },
                }
            },
            // 呼叫患者（具体患者）
            call: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_呼叫患者',
                options: {
                    text: '呼叫患者',
                    icon: '/icons/ionic_volume_medium.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('call');
                    },
                }
            },
            // 开始检查
            startExam: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_开始并书写',
                options: {
                    text: '开始检查',
                    icon: '/icons/antd_play_circle.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('startExam');
                    },
                }
            },
            // 开始检查
            start: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_开始检查',
                options: {
                    text: '开始检查',
                    icon: '/icons/antd_play_circle.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('start');
                    },
                }
            },
            // 完成检查
            completed: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_完成检查',
                options: {
                    text: '完成检查',
                    icon: '/icons/antd_check_circle.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('completed');
                    },
                }
            },
            // 检查参数记录
            checkParameterRecord: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_检查参数记录',
                options: {
                    text: '记录检查参数',
                    icon: 'textdocument',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('checkParameterRecord');
                    },
                }
            },
            // 紧急登记
            emergencyRegist: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_紧急登记',
                options: {
                    text: '紧急登记',
                    icon: '/icons/md_edit_note.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('emergencyRegist');
                    },
                }
            },
            // 其他操作
            others: {
                widget: 'dxDropDownButton',
                location: 'after',
                name: '技师_其他操作',
                options: {
                    text: '其他操作',
                    icon: 'more',
                    focusStateEnabled: false
                }
            },
            // 检查匹配（检查和未匹配的Study进行匹配）
            matchStudy: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_检查匹配',
                options: {
                    text: '检查匹配',
                    icon: '/icons/fa_link.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('matchStudy');
                    },
                }
            },
            // 重新检查
            recheck: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_重新检查',
                options: {
                    text: '重新检查',
                    icon: '/icons/md_replay.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('recheck');
                    },
                }
            },
            // 取消检查
            cancel: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_取消检查',
                options: {
                    text: '取消检查',
                    icon: '/icons/antd_close_circle.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('cancel');
                    },
                },
            },
            // 刷新
            refresh: {
                widget: 'dxButton',
                location: 'after',
                options: {
                    text: '刷新',
                    icon: 'refresh',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('refresh');
                    },
                },
            },
            // 刷新设置
            refreshSetting: {
                widget: 'dxDropDownButton',
                location: 'after',
                options: {
                    text: '刷新设置',
                    icon: 'preferences',
                    focusStateEnabled: false,
                    dropDownOptions: {
                        minWidth: '160px',
                    }
                },
            },
            // 自动刷新
            autoRefresh: {
                widget: 'dxButton',
                location: 'after',
                options: {
                    text: '启用自动刷新',
                    icon: 'refresh',
                    focusStateEnabled: false,
                    onClick: (e) => {
                        handleClick('autoRefresh', { component: e, key: 'refreshInterval', intervalKey: 'interval' });
                    },
                },
            },
            // 刷新间隔时间
            refreshInterval: {
                widget: 'dxButton',
                location: 'after',
                options: {
                    text: '设置间隔时间',
                    icon: 'clock',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('refreshInterval', { key: 'refreshInterval', intervalKey: 'interval' });
                    },
                },
            },

            //匹配Study页面
            // 自动刷新
            match_autoRefresh: {
                widget: 'dxCheckBox',
                location: 'after',
                options: {
                    text: '启用自动刷新',
                    icon: 'refresh',
                    focusStateEnabled: false,
                    onClick: (e) => {
                        handleClick('autoRefresh', { component: e, key: 'match_refreshInterval', intervalKey: 'match_interval' });
                    },
                },
            },
            // 刷新间隔时间
            match_refreshInterval: {
                widget: 'dxButton',
                location: 'after',
                options: {
                    text: '设置间隔时间',
                    icon: 'clock',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('refreshInterval', { key: 'match_refreshInterval', intervalKey: 'match_interval' });
                    },
                },
            },
            match_select: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_匹配_匹配选择',
                options: {
                    text: '匹配检查',
                    icon: 'check',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('matchSelect');
                    },
                }
            },
            match_select_report: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_匹配_匹配选择报告',
                options: {
                    text: '匹配报告',
                    icon: 'check',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('matchSelect', {type:'report'});
                    },
                }
            },
            // 查看报告
            viewReport: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_查看报告',
                options: {
                    text: '查看报告',
                    icon: '/icons/antd_file_pdf.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('viewReport');
                    },
                },
            },
            // 查看图像
            viewImage: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_查看图像',
                options: {
                    text: '查看图像',
                    icon: '/icons/antd_image.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('viewImage');
                    },
                },
            },
            // 挂起
            suspend: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_挂起',
                options: {
                    text: '挂起检查',
                    icon: '/icons/md_pause_circle_outline.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('suspend');
                    },
                },
            },
            // 过号
            pass: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_过号',
                options: {
                    text: '过号检查',
                    icon: '/icons/antd_redo.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('pass');
                    },
                },
            },
            // 申请会诊
            applyConsultation: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_申请会诊',
                options: {
                    text: '申请会诊',
                    icon: '/icons/x_exam.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('applyConsultation');
                    },
                },
            },
            // 查看检查事件
            examEvent: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_检查事件',
                options: {
                    text: '检查事件',
                    icon: '/icons/antd_thunderbolt.svg',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('examEvent');
                    },
                }
            },
            export: {
                widget: 'dxButton',
                location: 'before',
                name: '技师_导出列表',
                options: {
                    text: '导出列表',
                    icon: 'export',
                    focusStateEnabled: false,
                    onClick: () => {
                        handleClick('export');
                    },
                }
            }
        };
        for (const property in tools) {
            const item = tools[property];
            if (item.name) {
                item.visible = item.visible || (ris.verify(item.name) && item.visible !== false);
            }
            //if (property === 'call' || property === 'callNext') {
            if (property === 'callNext') {
                item.visible = item.visible && (!!ris.getStationCode());
            }
            if (property === 'start') {
                item.visible = !tools['startExam'].visible;
            }
            if (item.options) {
                if (item.hasOwnProperty('visible')) {
                    item.options.visible = item.visible;
                }
            }
        }
        if (tools["match_select"].visible) {
            tools["match_select_report"].visible = false;
            tools["match_select_report"].options.visible = tools["match_select_report"].visible;
        }
        return tools;
    };
})(jQuery);
